]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st-entry: Add API to set an actor as primary/secondary icon
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 10 Feb 2011 18:40:01 +0000 (19:40 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 21 Feb 2011 16:35:23 +0000 (17:35 +0100)
Currently an entry's primary/secondary icon can only be set by
filename. In order to allow using themed icons, add API to set
a generic ClutterActor as icon.

https://bugzilla.gnome.org/show_bug.cgi?id=642333

src/st/st-entry.c
src/st/st-entry.h

index 0cded5a49cf20e91a55d38d4baed751e25f59fb4..c963c98ed6bd314e9b0a496060ffe6f41c06471f 100644 (file)
@@ -868,9 +868,9 @@ _st_entry_icon_press_cb (ClutterActor       *actor,
 }
 
 static void
-_st_entry_set_icon_from_file (StEntry       *entry,
-                              ClutterActor **icon,
-                              const gchar   *filename)
+_st_entry_set_icon (StEntry       *entry,
+                    ClutterActor **icon,
+                    ClutterActor  *new_icon)
 {
   if (*icon)
     {
@@ -881,13 +881,9 @@ _st_entry_set_icon_from_file (StEntry       *entry,
       *icon = NULL;
     }
 
-  if (filename)
+  if (new_icon)
     {
-      StTextureCache *cache;
-
-      cache = st_texture_cache_get_default ();
-
-      *icon = (ClutterActor*) st_texture_cache_load_file_simple (cache, filename);
+      *icon = g_object_ref (new_icon);
 
       clutter_actor_set_reactive (*icon, TRUE);
       clutter_actor_set_parent (*icon, CLUTTER_ACTOR (entry));
@@ -898,6 +894,65 @@ _st_entry_set_icon_from_file (StEntry       *entry,
   clutter_actor_queue_relayout (CLUTTER_ACTOR (entry));
 }
 
+static void
+_st_entry_set_icon_from_file (StEntry       *entry,
+                              ClutterActor **icon,
+                              const gchar   *filename)
+{
+  ClutterActor *new_icon = NULL;
+
+  if (filename)
+    {
+      StTextureCache *cache;
+
+      cache = st_texture_cache_get_default ();
+
+      new_icon = (ClutterActor*) st_texture_cache_load_file_simple (cache, filename);
+    }
+
+  _st_entry_set_icon  (entry, icon, new_icon);
+}
+
+/**
+ * st_entry_set_primary_icon:
+ * @entry: a #StEntry
+ * @icon: (allow-none): a #ClutterActor
+ *
+ * Set the primary icon of the entry to @icon
+ */
+void
+st_entry_set_primary_icon (StEntry      *entry,
+                           ClutterActor *icon)
+{
+  StEntryPrivate *priv;
+
+  g_return_if_fail (ST_IS_ENTRY (entry));
+
+  priv = entry->priv;
+
+  _st_entry_set_icon (entry, &priv->primary_icon, icon);
+}
+
+/**
+ * st_entry_set_secondary_icon:
+ * @entry: a #StEntry
+ * @icon: (allow-none): an #ClutterActor
+ *
+ * Set the secondary icon of the entry to @icon
+ */
+void
+st_entry_set_secondary_icon (StEntry      *entry,
+                             ClutterActor *icon)
+{
+  StEntryPrivate *priv;
+
+  g_return_if_fail (ST_IS_ENTRY (entry));
+
+  priv = entry->priv;
+
+  _st_entry_set_icon (entry, &priv->secondary_icon, icon);
+}
+
 /**
  * st_entry_set_primary_icon_from_file:
  * @entry: a #StEntry
index 581ad4d5eb1c062a261c44f9712bfa9bf8d8dfbf..947705437593bf56f4522a616634d6eebc0523a1 100644 (file)
@@ -74,6 +74,10 @@ void                  st_entry_set_hint_text    (StEntry     *entry,
                                                  const gchar *text);
 G_CONST_RETURN gchar *st_entry_get_hint_text    (StEntry     *entry);
 
+void st_entry_set_primary_icon             (StEntry      *entry,
+                                            ClutterActor *icon);
+void st_entry_set_secondary_icon           (StEntry      *entry,
+                                            ClutterActor *icon);
 void st_entry_set_primary_icon_from_file   (StEntry     *entry,
                                             const gchar *filename);
 void st_entry_set_secondary_icon_from_file (StEntry     *entry,